// Link.cpp: implementation of the CLink class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Link.h"
#include <string>

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CLink::CLink()
{
	p = new CLink();
	p->next = NULL;
}

CLink::~CLink()
{

	t = p->next;
	while (t)
	{
		t = t->next;
	}

	while (p->next)
	{
		t = p;
		while (t->next)
		{
			t = t->next;
		}
		delete(t);
		t = NULL;
	}
	delete(p);
	p = NULL;
}

void CLink::add(any *a)
{
	int i = 0;
	t = p;

	while (a[i] != '\0')
	{
		CLink *n = new CLink();
		n->data = a[i];
		n->next = NULL;
		t->next = n;
		t = t->next;
		i++;
	}
}

void CLink::show()
{
	t = p->next;
	while (t)
	{
		printf("%c", t->data);
		t = t->next;
	}
}
